import React from 'react'
import { View, StatusBar, Platform, StyleSheet } from 'react-native'
import { Slot } from 'expo-router'
import UIConstants from '../constants/UIConstants'
import AppStorage from '../context/AppStorage'
import Toast from 'react-native-toast-message'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
export default function MyToplayout() {
    const insets = useSafeAreaInsets()
    return (
        <AppStorage.Provider value={{ loginToken: '' }}>
            <View style={styles.container}>
                {/* 仅Android需要自定义状态栏背景 */}
                {Platform.OS === 'android' && (
                    <View style={[styles.statusBarBackground, { height: insets.top }]} />
                )}
                <StatusBar
                    translucent={true}  // 关键：使状态栏透明
                    backgroundColor="transparent" // 设置为透明
                    barStyle="light-content"     // 设置状态栏图标为白色
                />
                <Slot />
            </View>
            <Toast />
        </AppStorage.Provider>
    )
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
    },
    statusBarBackground: {
        backgroundColor: UIConstants.COLOR_GREEN,
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        zIndex: 1000, // 确保在顶层
    }
})